#ifndef	__RS485_H__
#define __RS485_H__

#include "stdint.h"


#define RS485_SEND_ENABLE	GPIO_SetBits(GPIOB, GPIO_Pin_5)
#define RS485_SEND_DISABLE	GPIO_ResetBits(GPIOB, GPIO_Pin_5)

#define RS_RECV_BUF_LEN_MAX				128

typedef void (*RECV_FUNC)(uint8_t *data,uint8_t len);

struct s_RS_Receive
{
	uint8_t active;
	uint8_t len;
	uint8_t buf[RS_RECV_BUF_LEN_MAX];
	uint8_t flag;
};

struct s_RS_Send
{
	uint8_t valid;
	uint8_t cnt;
	uint8_t buf[128];
};

extern struct s_RS_Receive RS_Receive;

extern struct s_RS_Send RS_Send;

extern void RS_Init(void);

extern void RS_Receive_Data(uint8_t data);
extern void RS485_Senddata(uint8_t len, uint8_t *ptr);

extern void RS_Tmr_Fire(void);

extern void RS_App_Init(RECV_FUNC p_recv);

extern void RS485_App_Check(void);





















#endif //__RS485_H__
